package com.example.zk2.adapter

import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.base.entity.Goods
import com.example.zk2.R

class GoodsAdapter:BaseMultiItemQuickAdapter<Goods,BaseViewHolder>() {
    init {
        addItemType(0, R.layout.item_goods)
        addItemType(1, R.layout.item_goods)
    }
    override fun convert(holder: BaseViewHolder, item: Goods) {
        holder.setText(R.id.goods_name,item.storeName)
        holder.setText(R.id.goods_price,"￥${item.price}")
        holder.setText(R.id.goods_sale,"销量:${item.sales+item.ficti}")
        if(holder.itemViewType==0){
            Glide.with(context).load(item.image).into(holder.getView(R.id.goods_iv))
        }else{
            Glide.with(context).load(item.image).circleCrop().into(holder.getView(R.id.goods_iv))
        }
    }
}